package com.example.sqlitedemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import java.util.List;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        foodDaoImpl foodDaoimpl=new foodDaoImpl(this);
//        createDB();
//        addDate();
        List<Food> foodList=foodDaoimpl.findAll();
        for (int i=0;i<foodList.size();i++){
            Food food=foodList.get(i);
            Log.d("..."+i+food.getFoodname(),"00");
        }

    }

    //插入数据
//    private void addDate() {
//        helper = new MyDBOpenHelper(this);
//        sqLiteDatabase = helper.getReadableDatabase();
//        sqLiteDatabase.execSQL("insert into Food(foodname,foodprice,count) values('青椒肉丝',24,0)," +
//                "('西红柿炒蛋',12,0),('红烧鱼头',8,0),('红烧猪蹄',25,0),('紫菜蛋汤',10,0)");
//        Cursor cursor=sqLiteDatabase.query("Food",null,null,null,null,null,null);
//        while (cursor.moveToNext()){
//            Log.d(cursor.getString(1)+""+cursor.getString(2),"00000");
//        }
    }

//    private void createDB() {
//        helper = new MyDBOpenHelper(this);
//        sqLiteDatabase = helper.getReadableDatabase();
//    }

